package demo1;

import java.util.Scanner;

public class Test1 {
    public static void main1(String[] args) {
        try{
            func();
            System.out.println("6666");
        }catch(NullPointerException e){
            System.out.println("解决了空指针异常");
        }catch(ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("解决了数组异常");
        }
        System.out.println("其他代码");

    }
    public static void func(){
        int [] array = new int[5];
        System.out.println(array[5]);
    }

    public static void main(String[] args) {
        func2();
    }
  static int func2 (){
       Scanner scan = new Scanner(System.in) ;
       int i = scan.nextInt() ;
        try{
            System.out.println(2/i);
            return i ;
        }catch (ArithmeticException e){
            System.out.println("算算术异常");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("数组越界异常");
        }finally {
            System.out.println("关闭scan");
            scan.close();
        }
        if(scan != null){
            System.out.println("结束");
            scan.close();
        }
         return 0 ;
   }

}
